package com.stn.zjx.givingtreasure.widget;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;

import com.stn.zjx.givingtreasure.R;


/**
 * Created by 朱俊鑫 on 2018
 * 自定义微信弹窗
 * @author 朱俊鑫
 * @since 2018-3
 */
public class LoadingDialog extends Dialog {

    public View rootView;
    public LoadingDialog(Context context) {
        super(context, R.style.WXCustomDialog);
        initView();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        switch (keyCode){
            case KeyEvent.KEYCODE_BACK:
                if(LoadingDialog.this.isShowing())
                    LoadingDialog.this.dismiss();
                break;
        }
        return true;
    }

    private void initView(){
        setContentView(R.layout.dialog_loading_view);
        rootView=findViewById(R.id.rootView);
        setCanceledOnTouchOutside(true);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        WindowManager.LayoutParams attributes = getWindow().getAttributes();
        attributes.alpha=0.9f;
        getWindow().setAttributes(attributes);
        setCancelable(false);

    }
}